﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WMS.HelperClasses;

namespace WMS
{
	public partial class LoginForm : Form
	{
		private bool _authenticated = false;

		public LoginForm()
		{
			InitializeComponent();
		}

		private void button1_Click(object sender, EventArgs e)
		{
			if (Business.AuthenticateUser(UserNameTB.Text, PswdTB.Text))
			{   
				_authenticated = true;
				this.Close();
				return;
			}

			MessageBox.Show("بيانات الدخول غير صحيحة", "خطأ فى الدخول", MessageBoxButtons.OK, MessageBoxIcon.Stop);
		}

		private void LoginForm_FormClosing(object sender, FormClosingEventArgs e)
		{
			if (_authenticated)
                this.DialogResult = DialogResult.OK;
            else
                this.DialogResult = DialogResult.Abort;
		}
   }
}
